<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('人才资源库')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <p>职位类别：</p>
                                <select name="positionType" th:with="type=${@dict.getType('job_position_type')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <p>地区：</p>
                                <select name="area" th:with="type=${@dict.getType('job_area')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <p>薪资范围：</p>
                                <select name="salary" th:with="type=${@dict.getType('job_salary')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li class="select-time">
                                <p>生日：</p>
                                <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="startTime"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="endTime"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">

        var positionTypeDatas = [[${@dict.getType('job_position_type')}]];
        var areaDatas = [[${@dict.getType('job_area')}]];
        var salaryDatas = [[${@dict.getType('job_salary')}]];
        var prefix = ctx + "job/resumeLib";

        $(function() {
            var options = {
                url: prefix + "/list",
                modalName: "简历",
                columns: [
                {
                    field : 'resumeId', 
                    title : '简历id',
                    visible: false
                },
                    {
                        field : 'inviteId',
                        title : '邀请id',
                        visible: false
                    },
                    {
                        field : 'name',
                        title : '求职者姓名'
                    },
                    {
                        field : 'resumeName',
                        title : '简历名称'
                    },

                {
                    field : 'positionType', 
                    title : '职位类别',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(positionTypeDatas, value);
                    }
                },
                {
                    field : 'area', 
                    title : '地区',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(areaDatas, value);
                    }
                },
                {
                    field : 'salary', 
                    title : '薪资范围',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(salaryDatas, value);
                    }
                },
                    {
                        title: '操作',
                        align: 'center',
                        formatter: function(value, row, index) {
                            var actions = [];
                            if (row.view) {
                                actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)" onclick="view(\'' + row.resumeId + '\')"><i class="fa fa-edit"></i>查看简历</a> ');
                                if (row.inviteId == null) {
                                    actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)" onclick="invite(\'' + row.resumeId + '\')"><i class="fa fa-edit"></i>邀请面试</a> ');
                                } else {
                                    actions.push('<a class="btn btn-primary btn-xs " href="javascript:void(0)" onclick="viewInvite(\'' + row.inviteId + '\')"><i class="fa fa-edit"></i>邀请进度</a> ');
                                }
                                if (row.uploadStatus == '已上传附件') {
                                    actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)" onclick="downloadExcel(\'' + row.resumeId + '\', \'' + row.name + '\')"><i class="fa fa-download"></i>下载简历附件</a> ');
                                }
                                if (row.concernId == null) {
                                    actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)" onclick="concern(\'' + row.resumeId + '\')"><i class="fa fa-edit"></i>关注</a> ');
                                } else {
                                    actions.push('<a class="button btn-default btn-info " href="javascript:void(0)" onclick="cancelConcern(\'' + row.resumeId + '\')"><i class="fa fa-edit"></i>取消关注</a> ');
                                }
                            }
                            return actions.join('');
                        }
                    }
                ]
            };
            $.table.init(options);
        });

        function view(resumeId) {
            /* 查看企业信息 */
            var url = prefix + '/view/' + resumeId;
            $.modal.open("投递进度", url);

        }

        function concern(resumeId) {
            /* 关注简历 */
            var url = ctx + "job/resumeLib/concern";
            $.operate.post(url, { "resumeId": resumeId});
        }
        function cancelConcern(resumeId) {
            /* 取消关注简历 */
            var url = ctx + "job/resumeLib/cancelConcern";
            $.operate.post(url, { "resumeId": resumeId});
        }
        function invite(resumeId) {
            /* 邀请面试 */
            var url = ctx + "job/invite/add/" + resumeId;
            $.modal.open("面试邀请", url);
        }

        function viewInvite(inviteId) {
            var url = ctx + "job/invite/view/" + inviteId;
            $.modal.open("邀请进度", url);
        }

        function downloadExcel(resumeId, name) {
            var url = ctx + "job/resume/downloadFile";
            window.location.href = url + '?resumeId=' + resumeId + '&name=' + name;

        }
    </script>
</body>
</html>